//
//  GL20Renderer.h
//  Texture
//
//  Created by Yao Melo on 2/24/13.
//
//

#ifndef __Texture__GL20Renderer__
#define __Texture__GL20Renderer__

#include <iostream>
#include <OpenGLES/EAGL.h>
#include "Mathematics.h"
#include <vector.h>

#define VERTEX_ARRAY_ATTR 0
#define TEX_ARRAY_ATTR 1
#define NORMAL_ARRAY_ATTR 2

#include "SimShip.h"
#include "SimInvader.h"
#include "SimShot.h"
#include "SimExplosion.h"

@class OpenGLWaveFrontObject;
@class OpenGLTexture3D;


@interface GL20Renderer : NSObject
{
    OpenGLWaveFrontObject *shipMesh;
    OpenGLWaveFrontObject *invaderMesh;
    OpenGLWaveFrontObject *shotMesh;
    OpenGLWaveFrontObject *explosionMesh;
    OpenGLTexture3D *shipTexture; //C++ class
    OpenGLTexture3D *invaderTextrue;
    OpenGLTexture3D *explosionTextrue;
    OpenGLTexture3D *backgroundTexture;
    OpenGLTexture3D *gameoverTexture;
    OpenGLTexture3D *youwonTexture;
    GLuint texHandle,matHandle,colorMatHandle,colorHandle;
    GLuint textureProgram;
    GLuint colorProgram;
    MATRIX cameraMat;
    GLuint bgVBO,explosionVBO;
}

@property (nonatomic) MATRIX shipMotionMatrix;

-(id)init;

-(void)setCameraForShip:(Vec3)shipPosition withWidth:(float)width height:(float)height;
-(void)renderBackgroundWithWidth:(float)width height:(float)height;

-(void)renderShip:(SimShip*)ship;
-(void)renderInvaders:(std::vector<SimInvader>*)invaders withYAngle:(float)angle;

-(void)renderShots:(std::vector<SimShot>*)shots;
-(void)renderExplosions:(std::vector<SimExplosion>*)explosions;

-(void)loadGameoverTexture;

-(void)loadGamewinTexture;

-(void)resetTextureForPlaying;

-(void)renderGameoverWithWidth:(float)width height:(float)height;

-(void) renderGamewinWithWidth:(float)width height:(float)height;

@end
#endif /* defined(__Texture__GL20Renderer__) */
